/***********************************************************************************************************************************
 * Name:	Server_Rename.sql
 * Author:	Frank Figearo (frank.figearo@us.bbaaviation.com|frank@sqlnerd.me)
 * Summary:	Set the @@SERVERNAME to a new name.
 */
USE master;
DECLARE
	@NewName	SYSNAME = N'',
	@OldName	SYSNAME;
SELECT @OldName= [name] FROM sys.servers WHERE server_id = 0;
EXECUTE dbo.sp_dropserver @OldName;
EXECUTE dbo.sp_addserver @NewName, local;
SELECT [@@SERVERNAME]= @@SERVERNAME, [name], [data_source], [reminder]= N'The server must be restarted for change to take effect.' FROM sys.servers WHERE server_id = 0;
GO